#!/bin/sh
# This shell script used to cross compile u-boot for FL2440.
# Before excute this shell script, please download the source
# code patcket to here first.


UBOOT_SRC=u-boot-2010.09
IMAGE_NAME=u-boot.bin
INST_PATH=~/winxp/images
PATCH_FILE=./patch/fl2440-${UBOOT_SRC}.patch

if [ ! -d ${UBOOT_SRC} ] ; then
   if [ -f ${UBOOT_SRC}.tar.bz2 -a -f $PATCH_FILE ] ; then
        echo "==================================================="
        echo "+           Decompress u-boot now...              +"
        echo "==================================================="
        rm -rf ${UBOOT_SRC}
        tar -xjf ${UBOOT_SRC}.tar.bz2 

        echo "==================================================="
        echo "+                 Patching now...                 +"
        echo "==================================================="
        patch -p0 < $PATCH_FILE
   else
        echo "================================================================"
        echo "+       ERROR: Missing U-Boot Source Code Packet!              +"
        echo "+ Plese download ${UBOOT_SRC}.tar.bz2 to here and try again! +"
        echo "================================================================"
        exit;
   fi
fi

echo "==================================================="
echo "+              Build u-boot now...                +"
echo "==================================================="

cd ${UBOOT_SRC} 
make fl2440_config
make 

echo "==================================================="
echo "+           Install u-boot image now...           +"
echo "==================================================="
cp ${IMAGE_NAME} ${INST_PATH}

